home *** CD-ROM | disk | FTP | other *** search
/ Holt Researcher: American History / Holt Researcher: American History.iso / pc / modules / dbpictxt.dxr / 00008_Text & List Code.ls < prev    next >
Encoding:
Text File  |  2000-01-27  |  3.4 KB  |  160 lines

  1. global gDBPicttextVarList
  2.  
  3. on TextCopy
  4.   copyToClipBoard(member("texthold f"))
  5. end
  6.  
  7. on EvalKeyPressed
  8.   if IsKeyBoardEquivalentDown() then
  9.     MyObj = getaProp(gDBPicttextVarList, GetObjProp())
  10.     case the key of
  11.       "c":
  12.         TextCopy()
  13.       "p":
  14.         print(MyObj)
  15.       "s":
  16.         save(MyObj)
  17.     end case
  18.   end if
  19. end
  20.  
  21. on MakePlatformFileName xText
  22.   xText = RemoveReturns(xText)
  23.   xText = RemovePathDelimiters(xText)
  24.   if the machineType = 256 then
  25.     xText = ConcatenatePCWords(xText)
  26.     xText = translate(xText)
  27.     xText = RemoveSpaces(xText)
  28.     return xText
  29.   else
  30.     return xText
  31.   end if
  32. end
  33.  
  34. on ConcatenatePCWords xText
  35.   WordCount = the number of words in xText
  36.   if WordCount = 1 then
  37.     xText = char 1 to 8 of xText
  38.   else
  39.     if WordCount = 2 then
  40.       Word1 = char 1 to 4 of word 1 of xText
  41.       Word2 = char 1 to 4 of word 2 of xText
  42.       xText = Word1 & Word2
  43.     else
  44.       Word1 = char 1 to 4 of word 1 of xText
  45.       Word2 = char 1 to 3 of word 2 of xText
  46.       Word3 = char 1 of word 3 of xText
  47.       xText = Word1 & Word2 & Word3
  48.     end if
  49.   end if
  50.   return xText
  51. end
  52.  
  53. on SetFieldProps xMember
  54.   set the textFont of member xMember to GetFont()
  55.   member(xMember).scrollTop = 0
  56. end
  57.  
  58. on GetInsideRect xRect, xSprite
  59.   xLineSize = the lineSize of sprite xSprite
  60.   return xRect + rect(xLineSize, xLineSize, -xLineSize, -xLineSize)
  61. end
  62.  
  63. on GetFont
  64.   if the machineType = 256 then
  65.     xFont = "arial"
  66.   else
  67.     xFont = "helvetica"
  68.   end if
  69.   return xFont
  70. end
  71.  
  72. on GetRectHeight xRect
  73.   return getAt(xRect, 4) - getAt(xRect, 2)
  74. end
  75.  
  76. on RemoveBlankLines xText
  77.   ReturnString = xText
  78.   LineMax = the number of lines in ReturnString
  79.   repeat with rc = LineMax down to 1
  80.     LineText = line rc of ReturnString
  81.     if (LineText = EMPTY) or (LineText = " ") then
  82.       delete line rc of ReturnString
  83.       LineMax = the number of lines in ReturnString
  84.     end if
  85.   end repeat
  86.   return ReturnString
  87. end
  88.  
  89. on ParseLineBreak xText
  90.   repeat while xText contains "^"
  91.     Pos = offset("^", xText)
  92.     put RETURN into char Pos of xText
  93.   end repeat
  94.   return xText
  95. end
  96.  
  97. on RectToLoc xRect
  98.   l = getAt(xRect, 1)
  99.   t = getAt(xRect, 2)
  100.   R = getAt(xRect, 3)
  101.   b = getAt(xRect, 4)
  102.   xPoint = point(((R - l) / 2) + l, ((b - t) / 2) + t)
  103.   return xPoint
  104. end
  105.  
  106. on CreateLookUpList paramList
  107.   list = []
  108.   repeat with rc in paramList
  109.     append(list, getPos(paramList, rc))
  110.   end repeat
  111.   return list
  112. end
  113.  
  114. on LineItemCount xText
  115.   storeDelimiter = the itemDelimiter
  116.   the itemDelimiter = TAB
  117.   xNumber = the number of items in xText
  118.   the itemDelimiter = storeDelimiter
  119.   return xNumber
  120. end
  121.  
  122. on BlankLine xText
  123.   return (xText = EMPTY) or (xText = " ")
  124. end
  125.  
  126. on RemoveSpaces xText
  127.   ReturnString = xText
  128.   repeat while ReturnString contains " "
  129.     SpaceLoc = offset(" ", ReturnString)
  130.     delete char SpaceLoc of ReturnString
  131.   end repeat
  132.   return ReturnString
  133. end
  134.  
  135. on RemovePathDelimiters xText
  136.   if the machineType = 256 then
  137.     delimiter = "\"
  138.   else
  139.     delimiter = ":"
  140.   end if
  141.   repeat while xText contains delimiter
  142.     CharNum = offset(delimiter, xText)
  143.     if CharNum > 0 then
  144.       delete char CharNum of xText
  145.     end if
  146.   end repeat
  147.   return xText
  148. end
  149.  
  150. on DelBorderSpaces xText
  151.   ReturnString = xText
  152.   repeat while char 1 of ReturnString = " "
  153.     delete char 1 of ReturnString
  154.   end repeat
  155.   repeat while char length(ReturnString) of ReturnString = " "
  156.     delete char length(ReturnString) of ReturnString
  157.   end repeat
  158.   return ReturnString
  159. end
  160.